const { merge } = require('webpack-merge')

const commonConfig = require('./webpack.config.common.js')
 
const productionConfig = require('./webpack.config.pro.js')
 
const developmentConfig = require('./webpack.config.dev.js')

 
const build = env => {
  switch(env) {
    case 'development':
      return merge(commonConfig, developmentConfig);
    case 'production':
      return merge(commonConfig, productionConfig);
    default:
      throw new Error('No matching configuration was found!');
  }
}

module.exports = build(process.env.NODE_ENV)